package net.thxjj.mobileServer.entity;

import com.alibaba.fastjson.JSONObject;
import net.thxjj.mobileServer.util.Tools;

import java.util.HashMap;

public class ResponseModel{

	private static HashMap<String,Object> model=null;
	
	private ResponseModel() {}
	
	public static HashMap<String, Object> getModel(long code,String msg,Object data){
		model = new HashMap<String, Object>();
		model.put("code", code);
		model.put("msg", msg);
		model.put("data", data);
		return model;
	}
	
	public static HashMap<String, Object> getModel(ResultEnum resultEnum,Object data){
		model = new HashMap<String, Object>();
		model.put("code", resultEnum.getCode());
		model.put("msg", resultEnum.getMsg());
		model.put("data", data);
		return model;
	}

	public static HashMap<String, Object> getModel(GenieErrcode genieErrcode,Object data){
		model = new HashMap<String, Object>();
		model.put("code", genieErrcode.getError());
		model.put("msg", genieErrcode.getError_description());
		model.put("data", data);
		return model;
	}

	public static HashMap<String, Object> getGenieErrorCode(GenieErrcode genieErrcode){
		model = new HashMap<String, Object>();
		model.put("error", genieErrcode.getError());
		model.put("error_description", genieErrcode.getError_description());
		return model;
	}


	public static HashMap<String, Object> getGenieErrorCode(JSONObject header, String deviceId, GenieControlErrcode genieControlErrcode){
		HashMap<String,Object> model = new HashMap<String, Object>();
		if(!Tools.isEmpty(deviceId)){
			model.put("deviceId",deviceId);
		}
		model.put("error", genieControlErrcode.getError());
		model.put("error_description", genieControlErrcode.getError_description());


		HashMap<String,Object> result = new HashMap<>();
		 result.put("header",header);
		result.put("payload",model);

		return result;
	}


}
